import { Injectable } from '@angular/core';
import { _HttpClient } from '@core/services/http.client';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Injectable()
export class HttpService {
    // 麦尼哲
    // IP_PORT = 'http://139.196.189.173:8089';
    // 弘毅重远
    // IP_PORT = 'http://39.104.122.0:8280';
    // 田洪洋
    // IP_PORT = 'http://192.168.0.35:8083';
    // 吕博
    IP_PORT = 'http://192.168.0.19';
    // .net
    // PROJECT_PATH = '/api/SG_API';

    PROJECT_PATH = '/api';
    BASE_URL = this.IP_PORT + this.PROJECT_PATH;

    constructor(public Http: _HttpClient) {
    }

    /**
     * 获取项目列表
     * ident参数 cloud获取云端;private获取私有项目;
     * */
    getProject(ident: string, oparmas?: any): Promise<any> {
        let url;
        const parmas = oparmas || {};
        if (ident === 'private') {
            // 私有项目地址
            url = '/privateProject/getPrivateProjectList';
        } else if (ident === 'cloud') {
            // 云项目地址
            url = '/cloudProject/getCloudProjectList';
        } else if (ident === 'course') {
            // 课程项目地址
            url = '/CloudProject/getCourseProjectList';
        }

        return new Promise(res => {
            this.Http.get(this.BASE_URL + url, parmas).subscribe(data => {
                res(data);
            });
        });

    }

    getCloudByTechId(params) {
        return this.Http.get(this.BASE_URL + '/CloudProject/getCloudByTechId', params);
    }

    /**
     * 获取课程列表
     */
    getCourse(params) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getCoursList', params);
    }

    /**
     * 课程提交
     *  */
    CourseSubmit(params) {
        return this.Http.post(this.BASE_URL + '/CourseManager/addCours', params);
    }

    /**
     * 根据Id获取课程
     * */
    CatchCourse(params?: any) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getCoursInfo', params);
    }

    /**根据Id删除课程
     *
    */
    Coursedelete(params?: any) {
        return this.Http.post(this.BASE_URL + '/CourseManager/deleteCours', params);
    }

    /**根据Id删除课程
     *
    */
    CourseEdit(params) {
        return this.Http.post(this.BASE_URL + '/CourseManager/updateCours', params);
    }

    /**
     * 查看章节
     * */
    previewCourseChapter(params) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getCourseChapterList', params);
    }

    /**
     * 新增章节
     * */
    AddCourseChapter(params) {
        return this.Http.post(this.BASE_URL + '/CourseManager/saveCourseChapter', params);
    }

    /**
     * 删除章节
     * */
    DelCourseChapter(params) {
        return this.Http.post(this.BASE_URL + '/CourseManager/deleteCourseChapter', params);
    }


    /**
     * @version 1
     * @name 登录
     * @url /user/login.do
     * @params LoginName:string 用户名 , LoginPwd:string 密码
     * @type post
     * @response {"accesstoken":"f4ddd80e87724f8ea2bf564a0fac2887","code":"0","msg":"登录成功！"}
     * @summary code:0 成功 ,其他 失败
     * */
    login(params?: any) {
        return this.Http.post(this.BASE_URL + '/user/login', params);
    }

    // login(params?: any) {
    //     return this.Http.post('http://192.168.0.19:8083/api/SG_API/UserLogin', params);
    // }

    /**
     * @name 已关联云项目 --学校id
     * @url /CloudProject/getCloudListBySchId
     * */
    getCloudListBySchId(params) {
        return this.Http.get(this.BASE_URL + '/CloudProject/getCloudListBySchId', params);
    }

    /**
     * @name 保存关联云项目
     * @url /CloudProject/getCloudListBySchId
     * */
    SaveCloudSchool(params?: any) {
        return this.Http.post(this.BASE_URL + '/CloudProject/SaveCloudSchool', params);
    }

    /**
     * @name 已关联课程 --学校id
     * @url /CourseManager/getCloudListBySchId
     * */
    getCourseListBySchId(params) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getCoruseBySchool', params);
    }

    /**
     * @name 保存关联课程
     * @url /CourseManager/getCloudListBySchId
     * */
    SaveCousrseSchool(params?: any) {
        return this.Http.post(this.BASE_URL + '/CourseManager/SaveCoruseAndSchool', params);
    }

    /**
     * @name
     * @url /CloudProject/getSchoolCloudListBySchId
     * */
    getSchoolCloudListBySchId(params) {
        return this.Http.get(this.BASE_URL + '/CloudProject/getSchoolCloudListBySchId', params);
    }

    /**
     * @name
     * @url /CourseManager/getCourseListBySchool
     * */
    getCListBySchId(params) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getCourseListBySchool', params);
    }

    /**
     * @name
     * @url /CourseManager/getTeacherAndCourseList
     * */
    getCListByTechId(params) {
        return this.Http.get(this.BASE_URL + '/CourseManager/getTeacherAndCourseList', params);
    }

    /**
     * @name
     * @url /CourseManager/saveTeacherCourse
     * */
    SaveTeacherCourse(params?: any) {
        return this.Http.post(this.BASE_URL + '/CourseManager/saveTeacheCourse', params);
    }


    /**
     * @name
     * @url /CloudProject/SaveTeacherCloud
     * */
    SaveTeacherCloud(params?: any) {
        return this.Http.post(this.BASE_URL + '/CloudProject/SaveTeacherCloud', params);
    }

    /**
     * @name
     * @url /CloudProject/SaveTeacherCloud
     * */
    getCloudListByTechId(params) {
        return this.Http.get(this.BASE_URL + '/CloudProject/getCloudListByTechId', params);
    }

    getCloudBySchId(params) {
        return this.Http.get(this.BASE_URL + '/CloudProject/getCloudBySchId', params);
    }
    /*************班课管理*************/
    /**
     * @name 班级列表
     * @url /classManager/getClassManagerList
     * */
    classList(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getClassManagerList', params);
    }

    /**
     * @name 添加班级-课程列表
     * @url /classManager/getCourseListByUid
     * */
    getCourseListByUid(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getCourseListByUid', params);
    }

    /**
     * @name 添加班级
     * @url /classManager/getCourseListByUid
     * */
    AddClass(params?: any) {
        return this.Http.post(this.BASE_URL + '/classManager/addClassManager', params);
    }

    /**
     * @name 删除班级
     * @url /classManager/deleteClassById
     * */
    deleteClassById(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/deleteClassById', params);
    }

    /**
     * @name 学校ID 查看学生列表
     * @url /classManagerController/getStudentBySchId
     * */

    getStudentBySchId(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getStudentBySchId', params);
    }
    /**
     * @name 老师ID 查看学生列表
     * @url /classManagerController/getStudentByTechId
     * */

    getStudentByTechId(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getStudentByTechId', params);
    }
    /**
     * @name 班级ID 查看学生列表
     * @url /classManager/getStuListByClaId
     * */
    getStuListByClaId(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getStuListByClaId', params);
    }

    /**
     * @name 批量重置学生密码
     * @url /classManager/resetPassWord
     * */
    resetPassWord(params) {
        return this.Http.post(this.BASE_URL + '/classManager/resetPassWord', params);
    }
    getProjProcess(params?: any) {
        return this.Http.get(this.BASE_URL + '/privateProject/getProjProcess', params);
    }

    getBrainInfoList(params?: any) {
        return this.Http.post(this.BASE_URL + '/tablet/getBrainInfoList', params);
    }
    getGroupBattle(params?: any) {
        return this.Http.get(this.BASE_URL + '/privateProject/getGroupBattle', params);
    }

    /**
     * @name 课程管理列表
     * @url /courseManagerController/getCourseManagerList
     * */
    getCourseManagerList(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/getCourseManagerList', params);
    }

    /**
     * @name 创建课程时获取所有班级列表
     * @url /courseManagerController/getClassListByUid
     * */
    getClassListByUid(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/getClassListByUid', params);
    }


    /**
     * @name 班级修改课程列表接口
     * @url /classManagerController/getSelectOfCourListByClaId
     * */
    getSelectOfCourListByClaId(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getSelectOfCourListByClaId', params);
    }

    /**
     * @name 班级修改接口
     * @url /classManagerController/updateClassByClaId
     * */
    updateClassByClaId(params?: any) {
        return this.Http.post(this.BASE_URL + '/classManager/updateClassByClaId', params);
    }

    /**
     * @name 修改密码
     * @url /user/updatePassPad
     * */
    updatePassPad(params?: any) {
        return this.Http.post(this.BASE_URL + '/user/updatePassPad', params);
    }
    /**
     * @name 新建班级接口
     * @url /courseManagerController/addCourseManager
     * */
    addCourseManager(params?: any) {
        return this.Http.post(this.BASE_URL + '/courseManager/addCourseManager', params);
    }

    /**
     * @name 已关联课程接口
     * @url /classManagerController/getClaAndCourToPriProListByClaId
     * */
    getClaAndCourToPriProListByClaId(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/getClaAndCourToPriProListByClaId', params);
    }

    /**
     * @name 删除课程接口
     * @url /courseManagerController/deleteCourById
     * */
    deleteCourById(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/deleteCourById', params);
    }

    /**
     * @name 修改查询已选则的班级列表接口
     * @url /courseManagerController/deleteCourById
     * */
    getSelectOfClaListByCourId(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/getSelectOfClaListByCourId', params);
    }

    /**
     * @name 修改课程接口
     * @url /courseManagerController/updateCourseByCourId
     * */
    updateCourseByCourId(params?: any) {
        return this.Http.post(this.BASE_URL + '/courseManager/updateCourseByCourId', params);
    }

    /**
     * @name 查询已关联项目接口
     * @url /courseManagerController/getPrivateProjectByUserId
     * */
    getPrivateProjectByUserId(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/getPrivateProjectByUserId', params);
    }

    /**
     * @name 修改关联项目接口
     * @url /courseManagerController/updatePriProToCourByPId
     * */
    updatePriProToCourByPId(params?: any) {
        return this.Http.post(this.BASE_URL + '/courseManager/updatePriProToCourByPId', params);
    }

    /**
     * @name 批量删除班级接口
     * @url /classManagerController/deleteClaListByClaId
     * */
    deleteClaListByClaId(params?: any) {
        return this.Http.post(this.BASE_URL + '/classManager/deleteClaListByClaId', params);
    }

    /**
     * @name 删除学生接口
     * @url /classManagerController/deleteStuOfClaAndCour
     * */
    deleteStuOfClaAndCour(params?: any) {
        return this.Http.get(this.BASE_URL + '/classManager/deleteStuOfClaAndCour', params);
    }

    /**
     * @name 批量删除课程接口
     * @url /courseManagerController/deleteCourListByCourId
     * */
    deleteCourListByCourId(params?: any) {
        return this.Http.post(this.BASE_URL + '/courseManager/deleteCourListByCourId', params);
    }

    /*************公告管理*************/
    /**
     * @name 添加公告接口
     * @url /notice/add
     * */
    noticeAdd(params?: any) {
        return this.Http.post(this.BASE_URL + '/notice/add', params);
    }

    /**
     * @name 修改公告接口
     * @url /notice/update
     * */
    noticeUpdate(params?: any) {
        return this.Http.post(this.BASE_URL + '/notice/update', params);
    }

    /**
     * @name 删除公告接口
     * @url /notice/del
     * */
    noticeDel(params?: any) {
        return this.Http.post(this.BASE_URL + '/notice/del', params);
    }

    /**
     * @name 公告列表接口
     * @url /notice/list
     * */
    noticeList(params?: any) {
        return this.Http.get(this.BASE_URL + '/notice/list', params);
    }

    /**
     * @name 已关联班级
     * @url /courseManagerController/getCourAndClaToPriProByCourId
     * */
    getCourAndClaToPriProByCourId(params?: any) {
        return this.Http.get(this.BASE_URL + '/courseManager/getCourAndClaToPriProByCourId', params);
    }

    /*************用户管理*************/

    /*
    注册用户
     */
    userAdd(params?: any) {

        return this.Http.post(this.BASE_URL + '/user/add', params);
    }

    /*
查询用户列表
 */
    userList(params?: any) {

        return this.Http.get(this.BASE_URL + '/user/list', params);
    }

    /*
删除用户
*/
    userDel(params?: any) {
        return this.Http.post(this.BASE_URL + '/user/del', params);
    }

    /*
修改用户
*/
    userUpdate(params?: any) {
        return this.Http.post(this.BASE_URL + '/user/update', params);
    }


    getSchoolList(params?: any) {

        return this.Http.get(this.BASE_URL + '/user/getSchoolList', params);
    }

    SaveSchool(params?: any) {
        return this.Http.post(this.BASE_URL + '/user/SaveSchool', params);
    }

    deleteSchool(params?: any) {
        return this.Http.get(this.BASE_URL + '/user/deleteSchool', params);
    }

    getProjectsByType(type: string, params?: any) {
        let url;
        switch (type) {
            case 'private':
                url = '/privateProject/getPrivateProjectList';
                break;
            case 'cloud':
                url = '/cloudProject/getCloudProjectList.';
                break;
            default:
        }
        this.Http.get(this.BASE_URL + url, params);

    }

    /**
     * @name 场景文件上传
     * @url /fileUp/uploadFile
     * */

    upLoadFile(params) {
        return this.Http.post(this.BASE_URL + '/fileUp/uploadFile', params);
    }

    saveFlow(params) {
        return this.Http.post(this.BASE_URL + '/privateProject/addProjProcess', params);
    }


    /**
     * @name 场景上传
     * @url /privateProjectController/addScenes
     * */
    addScenes(params) {
        return this.Http.post(this.BASE_URL + '/privateProject/addScenes', params);
    }


    /**
     * @name 添加项目
     * @url /privateProjectController/addPrivateProject
     * */
    addProject(params) {
        return this.Http.post(this.BASE_URL + '/privateProject/addPrivateProject', params);
    }

    /**
     * @name 获取项目
     * @url  /privateProjectController/getPrivateProjectListById
     * */
    getProjectById(params) {
        return this.Http.get(this.BASE_URL + '/privateProject/getPrivateProjectListById', params);
    }

    /**
     * @name 修改项目
     * @url  /privateProjectController/updatePrivateProjectById
     * */
    updateProjectById(params) {
        return this.Http.post(this.BASE_URL + '/privateProject/updatePrivateProjectById', params);
    }

    /**
     * @name 图片上传
     * @url  /fileUp/uploadFile.do
     * */
    addImage(params) {
        return this.Http.post(this.BASE_URL + '/fileUp/uploadFile', params);
    }

    /**
     * @name 删除项目
     * @url  /privateProjectController/deletePrivateProjectById
     * */
    deleteProjectById(params) {
        return this.Http.get(this.BASE_URL + '/privateProject/deletePrivateProjectById', params);
    }

    /**
     * @name 根据n_id获取场景数据
     * @url  /phoneAppController/getScenesById
     * */
    getScenesById(params) {
        return this.Http.get(this.BASE_URL + '/phoneApp/getScenesById', params);
    }

    /*************统计分析*************/

    /*项目类型列*/
    projectType() {
        return this.Http.get(this.BASE_URL + '/statistical/projectType.do');
    }

    /*项目统计*/
    projectList(params) {
        return this.Http.get(this.BASE_URL + '/statistical/projectList', params);
    }

    /*课堂演练列表*/
    projectClassList(params) {
        return this.Http.get(this.BASE_URL + '/statistical/projectClassList', params);
    }

    /*课堂演练-学生详情*/
    exercisesStudentInfo(params) {
        return this.Http.get(this.BASE_URL + '/statistical/exercisesStudentInfo', params);
    }

    /*课堂演练-学生详情-点评*/
    addStudentComment(params) {
        return this.Http.post(this.BASE_URL + '/statistical/addStudentComment', params);
    }

    /*模拟演练列表*/
    exercisesSimuliation(params) {
        return this.Http.get(this.BASE_URL + '/statistical/projectClassList', params);
    }

    /*云项目引用到我的项目*/
    addMySubjuct(params) {
        return this.Http.get(this.BASE_URL + '/cloudProject/quoteCloudProject', params);
    }

    /*项目演练快速入口*/
    quickEntryProject(params) {
        return this.Http.post(this.BASE_URL + '/simulation/addSimulation', params);
    }

    /* 我的项目 授课按钮 弹框*/
    getClassListByPid(params) {
        return this.Http.get(this.BASE_URL + '/tablet/getClassByPId', params);
    }

    /* 我的项目 授课按钮 弹框*/
    getCourseListById(params) {
        return this.Http.get(this.BASE_URL + '/tablet/getCourseById', params);
    }

    /**
     * 预览项目场景
     * @/privateProjectController/getPreviewScene
     */
    getPreviewScene(params) {
        return this.Http.post(this.BASE_URL + '/privateProject/getPreviewScene', params);
    }

    /**
     * 超管 教师列表
     * @/classManager/getTeacherList
     */
    getTeacherList(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getTeacherList', params);
    }

    /**
     * 超管 获取所有专业列表
     * @/classManager/getMajroList
     */
    getMajorList(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getMajorList', params);
    }

    /**
     * 超管 获取当前老师已关联专业
     * @/classManager/getMajTech
     */
    getMajTech(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getMajTech', params);
    }

    /**
     * 超管 修改老师关联专业
     * @/classManager/addMajTech
     */
    addMajTech(params) {
        return this.Http.post(this.BASE_URL + '/classManager/addMajTech', params);
    }

    /**
     * 超管 获取当前专业班级列表
     * @/classManager/getMajTech
     */
    getClassByMajId(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getClassByMajId', params);
    }

    /**
     * 超管 修改已关联班级
     * @/classManager/addClassByMajId
     */
    addClassByMajId(params) {
        return this.Http.post(this.BASE_URL + '/classManager/addClassByMajId', params);
    }

    /**
     * 超管 获取已关联班级
     * @/classManager/getClassMaj
     */
    getClassMaj(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getClassMaj', params);
    }

    /**
     * 超管 新建老师
     * @/classManager/SaveTeacher
     */
    saveTeacher(params) {
        return this.Http.post(this.BASE_URL + '/classManager/SaveTeacher', params);
    }

    /**
     * 超管 删除老师
     * @/classManager/SaveTeacher
     */
    removeTeacher(params) {
        return this.Http.post(this.BASE_URL + '/classManager/deleteTeacher', params);
    }

    /**
     * 超管 编辑按钮
     * @/classManager/getTeacherInfo
     */
    getTeacherInfo(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getTeacherInfo', params);
    }

    /**
     * 超管 新建专业
     * @/classManager/SaveTeacher
     */
    saveMajor(params) {
        return this.Http.post(this.BASE_URL + '/classManager/saveMajor', params);
    }

    /**
     * 超管 编辑专业
     * @/classManager/getMajorInfo
     */
    getMajorInfo(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getMajorInfo', params);
    }

    /**
     * 超管 删除专业
     * @/classManager/deleteMajor
     */
    deleteMajor(params) {
        return this.Http.post(this.BASE_URL + '/classManager/deleteMajor', params);
    }

    /**
     * 超管 根据专业id获取班级列表
     * @/classManager/getClassList
     */
    getClassList(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getClassList', params);
    }

    /**
     * 超管 保存班级
     * @/classManager/saveClass
     */
    saveClass(params) {
        return this.Http.post(this.BASE_URL + '/classManager/saveClass', params);
    }

    /**
     * 超管 删除班级
     * @/classManager/saveClass
     */
    deleteClass(params) {
        return this.Http.get(this.BASE_URL + '/classManager/deleteClass', params);
    }

    /**
     * 超管 专业获取已关联教师
     * @/classManager/getTeacherMajor
     */
    getTeacherMajor(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getTeacherMajor', params);
    }

    /**
     * 超管 保存专业关联教师
     * @/classManager/addTeacherMaor
     */
    addTeacherMajor(params) {
        return this.Http.post(this.BASE_URL + '/classManager/addTeacherMajor', params);
    }

    /**
     * 获取演练记录列表
     * @params key:string ps:number pi:number
     */
    getExercisesList(params) {
        return this.Http.get(this.BASE_URL + '/simulation/getExercisesList', params);
    }

    /**
     * 获取演练ID 获取学生演练记录
     * @params sim_id
     */
    getExercisesInfoBySimId(params) {
        return this.Http.get(this.BASE_URL + '/simulation/getExercisesInfoBySimId', params);
    }

    /**
     * 教师评分评价
     * @params u_id,sim_id,techScore,Comment
     */
    updateScore(params) {
        return this.Http.post(this.BASE_URL + '/simulation/updateScore', params);
    }

    /**
     * 超管 根据班级id获取学生列表
     * @/classManager/getStudentByClaId
     */
    getStudentByClaId(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getStudentByClaId', params);
    }

    /**
     * 超管 根据老师id获取班级列表
     * @/classManager/getClassListByTechId
     */
    getClassListByTechId(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getClassListByTechId', params);
    }


    getTeacherInfoListByMajId(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getTeacherInfoListByMajId', params);
    }

    /**
     * 超管 根据学生id删除关联专业和班级
     * @/classManager/deleteStudent
     */
    deleteStudent(params) {
        return this.Http.get(this.BASE_URL + '/classManager/deleteStudent', params);
    }

    /**
     * 超管 根据班级id获取审核列表
     * @/classManager/getCheckStuList
     */
    getCheckStuList(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getCheckStuList', params);
    }

    /**
     * 超管 申请加入班级 通过或驳回
     * @/classManager/checkStudent
     */
    checkStudent(params) {
        return this.Http.get(this.BASE_URL + '/classManager/checkStudent', params);
    }

    /**
     * 获取班级下已关联的项目
     * @params u_id,sim_id,techScore,Comment
     * /api/classManager/getProjectListByClaId
     */
    getProjectListByClaId(params) {
        return this.Http.get(this.BASE_URL + '/classManager/getProjectListByClaId', params);
    }

    /**
     * pc端开始演练
     * @params cla_id p_id p_type exercisetypes
     * api/simulation/addSimulation
     */
    addSimulation(params) {
        return this.Http.post(this.BASE_URL + '/simulation/addSimulationPC', params);
    }
    getSixHatAnalogGroList(params) {
        return this.Http.get(this.BASE_URL + "/tablet/getSixHatAnalogGroList", params)
    }

    isUser(params?: any) {
        return this.Http.post(this.BASE_URL + '/classManager/isUser', params);
    }

    /**
     * @name 教师引用课程
     * @url /CourseManager/QuoteCourseProject
     * */
    QuoteCourseProject(params?: any) {
        return this.Http.get(this.BASE_URL + '/CourseManager/QuoteCourseProject', params);
    }
}
